<template>
  <div class="home">
    <h1>子应用</h1>
    <p>通过主应用登录session,在子页面获取数据</p>
    <p v-if="this.token">获取到的SessionId: {{this.token}}</p>
    <div class="btn" @click="getInfo">获取数据</div>
    <ul>
      <li v-for="item in list" :key="item.projectUuid">{{item.projectName}}</li>
    </ul>
  </div>
</template>

<script>
import SharedModule from '@/shared/store'

export default {
  name: 'home',
  data() {
    return {
      list: '',
      token: ''
    }
  },
  created() {
    this.token = SharedModule.getShared().getters.getToken
    console.log(this.token)
    if (!this.token) {
      alert('未登录')
      setTimeout(() => {
        this.$goLogin()
      }, 1200)
    }
  },
  methods: {
    getInfo() {
      this.$axios.post('/manager/getToNowProjectList').then(res => {
        this.list = res.data.result
      })
    }
  }
}
</script>

<style lang="less" scoped>
.home {
  ul {
    overflow: hidden;
  }
  li {
    padding: 10px 0;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease-in;
    &:hover {
      transform: scale(1.2);
    }
  }
  p {
    padding: 15px;
  }
}
.btn {
  color: rgb(75, 75, 75);
  border-radius: 4px;
  border: 1px solid #cccccc;
  width: 120px;
  margin: 15px auto;
  font-size: 14px;
  padding: 2px 6px 3px;
  background-color: rgb(255, 255, 255);
  border-radius: 20px;
  border-style: solid;
  border-color: rgb(184, 215, 251);
  border-width: 2px;
  font-style: normal;
  font-weight: normal;
  text-align: center;
  cursor: pointer;
  line-height: 30px;
  height: 30px;
}
</style>
